package com.atis.warplot.database.utils;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class SessionHibernate {

	// Singleton
	private static SessionHibernate instance = new SessionHibernate();

	private SessionFactory sessionFactory;

	// --------------------------------------------------------------------------------

	private SessionHibernate() {

		Configuration configuration = new Configuration();
		configuration.configure( //
				"/com/atis/warplot/database/utils/hibernate.cfg.xml");
		sessionFactory = configuration.buildSessionFactory();

	}

	// --------------------------------------------------------------------------------

	public static SessionHibernate getInstance() {
		return instance;
	}

	// --------------------------------------------------------------------------------

	public Session getSession() {
		return sessionFactory.openSession();
	}

	// --------------------------------------------------------------------------------

}
